package com.sls.nzdapplication.ui.custom;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;

import com.sls.nzdapplication.R;
import com.sls.nzdapplication.ui.custom.base.MyBaseIconView;
import com.sls.nzdapplication.util.LogUtil;


public class AddCableChannelView extends MyBaseIconView {
    private static final String TAG = "MapLayerView";

    private AddCableChannelView.OnAddCableChannelViewListener onAddCableChannelViewListener;


    public AddCableChannelView(Context context) {
        this(context, null);
    }

    public AddCableChannelView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public AddCableChannelView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(onAddCableChannelViewListener == null){
                    return;
                }
                onAddCableChannelViewListener.onAddCableChannelViewClick();
            }
        });
    }


    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        LogUtil.d(TAG, "width=" + getMeasuredWidth() + ",height=" + getMeasuredHeight());
    }

    @Override
    public boolean createBackground() {
        setIconBackground(R.drawable.channel_icon);
        return true;
    }

    @Override
    public boolean createIcon() {
        setBackgroundResource(R.drawable.icon_middle_selector);
        return true;
    }

    public void setAddCableChannelViewListener(AddCableChannelView.OnAddCableChannelViewListener listener){
        if(listener != null){
            onAddCableChannelViewListener = listener;
        }
    }

    public interface OnAddCableChannelViewListener{

        void onAddCableChannelViewClick();
    }
}
